//
//  CryptoCR2.m
//  Interventix
//
//  Created by Diego on 06/12/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "CryptoCR2.h"
#import "CommonCrypto/CommonCryptor.h"
#import "NSData+AESCrypt.h"
#import "NSString+AESCrypt.h"
#import "ASIHTTPRequest.h"
#import "ASIFormDataRequest.h"
#import "NSData+Conversion.h"
#import "Define.h"

@implementation CryptoCR2

+(NSString *) encrypt:(NSString *) valueToCR2{
    NSString *crypt = [valueToCR2 AES128EncryptWithKey:AES_KEY];
    NSData *dat = [crypt dataUsingEncoding:NSUTF8StringEncoding];
    return [dat hexadecimalString];
    
}

+(NSString *) decrypt:(NSString *) hexString{
    NSData *dat = [NSData dataFromHexString:hexString];
    
    NSString *crypt = [[NSString alloc] initWithBytes:[dat bytes] length:[dat length] encoding:NSUTF8StringEncoding];
    return [crypt AES128DecryptWithKey:AES_KEY];
}
                       


@end
